home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 149 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  5.8 KB

  1. From: John Max Skaller <maxtal@suphys.physics.su.oz.au>
  2. Message-ID: <3108FE66.FFD@suphys.physics.su.oz.au>
  3. X-Original-Date: Sat, 27 Jan 1996 02:16:38 +1000
  4. Path: in1.uu.net!bounce-back
  5. Date: 26 Jan 96 19:17:20 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: auto_ptr again
  9. Organization: MAXTAL
  10. References: <ADxYD_mKQD@qsar.chem.msu.su> <4djrn4$js1@engnews1.Eng.Sun.COM>
  11. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMQkpx+EDnX0m9pzZAQF+RQF+M9p3YyDCSKCvTpYbc9FVCjto8V0bb0jD
  14.     6JkXL5mi/s7OFWgJVmfIvS8SXvOpxQts
  15.     =sMfr
  16.  
  17. Steve Clamage wrote:
  18. > In article mKQD@qsar.chem.msu.su, "Eugene Radchenko"
  19. > <eugene@qsar.chem.msu.su> writes:
  20. > >I would like to suggest returning to the definition of auto_ptr. The fact
  21. > >is, in current form it is almost unusable for most things due to its
  22. > >underlining concept of a single strict ownership. Actually, we need
  23. > >multiple-instance auto_ptr. 
  24.  
  25. > That point has been beaten to death in the C++ committee and also in
  26. > this forum. Some people felt an auto_ptr should be able to have multiple
  27. > owners, but people with experience with this kind of design persuaded
  28. > the committee that auto_ptrs are too hard to use unless they can have
  29. > only a single owner. Thus, ownership is transferred upon copying.
  30.  
  31.     This is fairly biased picture -- from my perspective.
  32.     Here's what actually happened -- from my perspective.
  33.  
  34.     1. There was a clear need from some kind of automatic
  35.        storage management for pointers, particularly in the light of
  36.        exceptions.
  37.  
  38.     2. Australia, New Zealand and the UK made "Exception safe programming"
  39.        with pointers National Body Issues. Not everyone was happy at
  40.        having to deal with this. [In retrospect, they might have been
  41.        right.]
  42.  
  43.     3. I submitted the first design to the Library reflector.
  44.        The class was called "Holder". Mike Vilot (LWG leader) did some
  45.             [[ Moderator's note: for the uninitiated,              ]]
  46.             [[ "LWG" == "Library Working Group". -moderator (fjh). ]]
  47.         work on it. Holder had an important property -- it was NOT copyable.
  48.  
  49.        I also said a reference counted smart pointer type
  50.        was necessary, although I didn't have an adequate design handy.
  51.        This was the kind to use when you needed copyability.
  52.  
  53.     4. The design was eventually taken over by Greg Colvin.
  54.        (Greg is a top designer, his first proposal was extremely
  55.         ambitious -- garbage collection!)
  56.  
  57.     5. Despite REPEATED attempts, Greg was not able to engineer
  58.        a proposal for a reference counted pointer that the committee
  59.        could agree on. [But I currently use his design myself,
  60.        it will be published in my book as "ColvinPtr"]
  61.  
  62.     6. Because this left a huge gaping hole, the Holder class -- which
  63.        had been renamed "auto_ptr" by this time, was mangled to try to
  64.            serve two masters. The semantics were changed to
  65.        "token passing", which was never in my original Holder class,
  66.         nor implied by a reference counting implementation,
  67.        and does not, in my opinion, meet Australia's requirements.
  68.  
  69.     7. Then it was discovered that the current specification is useless
  70.        because it requires a non-const argument to the copy constructor.
  71.  
  72.     8. Just today I read Greg has proposed using "mutable" to fix
  73.        the problem.  The semantics have changed radically in this
  74.        proposal: now ALL the auto_ptr objects can access the
  75.        object, but only one is designated as the owner.
  76.  
  77.     For the record, I have no objections to token passing per se --
  78. it's just another storage management idiom. What I object to is the use
  79. of copy syntax for a non-copying operation, and the fact that this
  80. idiom is far less useful than reference counting, and not constrained
  81. enough for a Holder style class.
  82.  
  83.     It is, for example, useless as a replacement
  84. for pointers in classes whose constructors might throw exceptions,
  85. since copying the object silently transfers ownership. The new
  86. object will then promptly destroy the delegee object, invalidating
  87. the pointer in the old one prematurely.
  88.  
  89. > That is, single ownership is a deliberate design decision based on the
  90. > semantics an auto-ptr should have. It is not an implementation issue.
  91.  
  92.     I do not agree. It is definitely an implementation
  93. issue when the proposed semantics are unimplementable without
  94. resorting to hackery -- in this case "mutable".
  95.  
  96.     And the current attempt to fix the problem is an not an example
  97. a deliberate design decision, but a brilliant designer trying
  98. to cope with the political situation in the committee -- changing
  99. the specification of auto_ptr is acceptable, creating
  100. a new class is not.
  101.  
  102. > Unless someone can present new evidence that shows the arguments in favor
  103. > of single ownership are wrong, and in addition shows that multiple
  104. > ownership is always better, this subject won't be reopened in the committee.
  105.  
  106.     I don't agree with that either. You are making
  107. the committee sound logical. It isn't. It is political.
  108.  
  109.     The committee will (correctly, IMHO), not reopen
  110. the issue unless a National Body (or three!) requires it.
  111. No amount of argument or evidence is relevant. The committee
  112. will tolerate fudging the semantics of the existing class,
  113. but won't address the _original_ National Body requirements.
  114.  
  115.     Will I find myself annoyed at this outcome, the need
  116. to stablise the language overrides any but the most
  117. fundamental design faults in the core language itself -- IMO.
  118. So we may have to live with auto_ptr -- but we don't HAVE to
  119. use it.
  120.  
  121. -- 
  122. John Max Skaller               voice: 61-2-566-2189
  123. 81 Glebe Point Rd              fax:   61-2-660-0850
  124. GLEBE NSW 2037                 web: http://www.maxtal.com.au/~skaller/
  125. AUSTRALIA                      email: skaller@maxtal.com.au
  126. ---
  127. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  128.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  129.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  130.